<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class SeeChannel
{
    protected $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

    protected function script()
    {
        return <<<SCRIPT

layui.use('layer', function(){
        var layer = layui.layer;

        $('.seechannel').click(function () {
           var that = this;
           var cid = $(that).attr('data-id');
           var remark = $(that).attr('data-remark');
           var merchant = $(that).attr('data-merchant');
           var index = layer.open({
               type: 2,
               content: '/html/channel_qrcode.html?cid='+cid+'&remark='+remark+'&merchant='+merchant,
               area: ['500px', '600px'],
               yes: function(index, layero){
                   layer.close(index);
               }
           });

       });

    });

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

//        return "<a class='btn btn-xs btn-success fa grid-check-row' data-id='{$this->id}'>查看</a>";
        return '';
    }

    public function __toString()
    {
        return $this->render();
    }
}